package com.itheima.text5;

import java.util.Scanner;

public class Demo5 {
    public static void main(String[] args) {
        Scanner sc = new Scanner(System.in);
        System.out.println("输入汉诺塔的层数");
        int line = sc.nextInt();
        int time = hanoi(line);
        System.out.println(time);

    }

    public static int hanoi(int i) {
        if (i == 1) {
            return 1;
        } else {
            //每增加一层,次数就是之前的2倍+1\
            return hanoi(i - 1) + 1 + hanoi(i - 1);
        }
    }
}
